<template>
  <div>
    <bread :second="'数据统计'" :third="'数据报表'"></bread>
    <el-card class="box-card" style="margin-top:15px ">
      <!-------------------------------- 搜索栏 ------------------------------------------>
      <el-row :gutter="20">
        <el-col :span="8">
          <div class="grid-content bg-purple">
            <el-input
              placeholder="请输入内容"
              v-model="queryInfo.query"
              class="input-with-select"
              clearable
              @clear="getOrderList()"
            >
              <el-button slot="append" icon="el-icon-search" @click="getOrderList()"></el-button>
            </el-input>
          </div>
        </el-col>
      </el-row>
      <!---------------------------------- 表格 ------------------------------------------>
      <el-table :data="tableData" stripe style="width: 100%;margin-top:15px" border>
        <el-table-column label="#" width="50" type="index"></el-table-column>
        <el-table-column prop="order_number" label="订单编号"></el-table-column>
        <el-table-column prop="order_price" label="订单价格"></el-table-column>
        <el-table-column prop="pay_status" label="是否付款">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.pay_status" type="danger">未付款</el-tag>
            <el-tag v-else>已付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货"></el-table-column>
        <el-table-column prop="create_time" label="下单时间">
          <template slot-scope="scope">{{scope.row.create_time| format}}</template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope>
            <el-button type="warning" size="mini">编辑</el-button>
            <el-button type="danger" size="mini">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!---------------------------------- 分页 ---------------------------------------->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.pagenum"
        :page-sizes="[10, 20, 30, 50]"
        :page-size="queryInfo.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </el-card>
  </div>
</template>
           
<script>
import { getOrderList_api } from "@/api/index.js";
export default {
  data() {
    return {
      queryInfo: {
        query: "",
        pagenum: 1,
        pagesize: 10
      },
      total: 0,
      tableData: []
    };
  },
  created() {
    this.getOrderList();
  },
  methods: {
    //渲染页面---------------------------
    async getOrderList() {
      const { data: res } = await getOrderList_api(this.queryInfo);
      console.log(res, 111111);
      this.tableData = res.data.goods;
      this.total = res.data.total;
    },
    //分页功能--------------------
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.queryInfo.pagesize = val;
      this.getOrderList();
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.queryInfo.pagenum = val;
      this.getOrderList();
    }
  }
};
</script>
<style scoped>
</style>